package cn.caipengbo.action;

import cn.caipengbo.domain.User;
import cn.caipengbo.service.Service;
import cn.caipengbo.service.impl.ServiceImpl;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

/**
 * Created by Myth on 2/9/2017.
 */
public class LoginAction extends ActionSupport implements ModelDriven<User> {
    private Service service = new ServiceImpl();
    private User user= new User();

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
    public String login() {
        System.out.println(user.toString());
        User loginedUser = service.login(user);
        if (loginedUser == null) {
            return ERROR;
        } else {
            return SUCCESS;
        }
    }
    @Override
    public User getModel() {
        return user;
    }
}
